<?php 
include "includes/session.php";
include "includes/comunes.php";
require_once("includes/paginator.class.php");
$pages = new Paginator;

//busco datos del accionista

$sql="select * from vehiculo where idAuto=".$_GET['aut_id'];
$resPer=cons_sql_up($sql);
$regPer=mysql_fetch_array($resPer);



$sql="select * from movcaja ";
//armo el Where de la consutla
$where=" where movVehiculo=".$_GET['aut_id'];
$where.=" order by movId desc, movFecha desc "   ;


//realizo la consulta paro obtener los totales

$result= cons_sql_up($sql.$where);
//finc consulta

$pages->items_total = mysql_num_rows($result);
$pages->mid_range = 9;
$pages->paginate();
$result=  $result= cons_sql_up($sql.$where.$pages->limit);
//echo $sql.$where.$pages->limit;die();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta HTTP-EQUIV="refresh" CONTENT="300"/>
<title>Sistema de Gestion de Vehiculos</title>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->

<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->



<script language="JavaScript" type="text/javascript">
$(function()
{

//        funcion que implementa combos
	$('#marca').chainSelect('#modelo','combomarcamodelo.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
        $('#modelo').chainSelect('#version','combomodeloversion.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
        
           $('#venpro').chainSelect('#venloc','comboprolocalidad.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
//        fin funcion

//          funcion datapicker

     <!--  $( "#fechad" ).datepicker({
       //  dateFormat: "yy-mm-dd"
//
//      });
//	  
//	  $( "#fechah" ).datepicker({
//         dateFormat: "yy-mm-dd"
//
//      });-->
       
//             funcion

//funcion autocomplete
   
		
		   $( "#vendedor" ).autocomplete({
			source: "autoAccionista.php"
		});


//fin funcion




  $('#flex1').flexigrid({
      colModel : [
                
		{display: 'Fecha.', name : 'accionistaId', width : 60, sortable : true, align: 'center'},
		{display: 'Tipo Gasto', name : 'dni', width : 150, sortable : true, align: 'left'},
		{display: 'Concepto', name : 'nomyape', width : 350, sortable : true, align: 'left'},
		{display: 'Ingresa', name : 'fecha', width : 100, sortable : true, align: 'left'},
		{display: 'Egresa', name : 'fecha', width : 100, sortable : true, align: 'left'}
  ],
                width: 450,
                height: 1000
              
  });
<?php for ($i=1;$i<30;$i++):?>
  $('#fila<?php echo $i?>').tooltip({
      track: true
    });
 
<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#visualizar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
 <?php for ($i=1;$i<30;$i++):?>
  $('#editar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#imprimir<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#tratar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
});
</script>



</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal">
           <?php include 'includes/submenu.php';?>  
           <img src="img/movimientos.jpg" width="25" height="25" border="0"/> Gastos Asociados a Vehiculos
           </div>
       
       <div class="contenedorpedido">
       <form id="boletocompra" name="boletocompra" method="POST" action="ListadoAccionistas.php">
        <fieldset>
             <legend><b>Datos del Vehiculo</b></legend>
             <table  width="100%">
                   <tr>
                      <input type="hidden"  value="2" name="origen"> 
                      
                      <input type="hidden"  value="<?php echo $_GET['aut_id'] ?>" name="aut"> 
                      <td class="textotablamenuform">Dominio/Patente</td>
                      <td class="textotablamenuform">
                           <input type="text" class="campo_form" value="<?php echo $regPer['patente'] ?>"  id="vendni" name="vendni" disabled style="width:80%;"> 
                          
                      </td>
                      <td class="textotablamenuform">Nombre y Apellido</td>
                      <td class="textotablamenuform" colspan="3">
                           <input type="text" class="campo_form"   name="venape" disabled value="<?php echo obtener_nombre_marca($regPer['idMarca'])." - ".obtener_nombre_modelo($regPer['idModelo'])." - ".obtener_nombre_version($regPer['idVersion']) ?>">
                               
                      </td> 
                   </tr>
                   
                   
                   <tr>
                   <td colspan="5">
                    <fieldset>
                    <legend><b>Estado de Cuenta</b></legend><table width="100%" border="0">
  <!--<tr>
    <td colspan="2" class="textotablamenuform">&nbsp;Valor de Venta: </td>
    <td colspan="2" class="textotablamenuform">&nbsp;<span style=" font-size:18px; color:#000;">$ <?php //echo $regPer['precioVenta'] ?></span></td>
  </tr> -->
  <tr>
    <td class="textotablamenuform">&nbsp;Valor de Toma : </td>
    <td class="textotablamenuform">&nbsp;<span style="color: green;">$ <?php echo $regPer['precioToma'] ?></span></td>
    <td class="textotablamenuform">&nbsp;Total Gastos :</td>
    <td class="textotablamenuform">&nbsp;<span style="color: red;">$ <?php echo obtener_total_egresos_vehiculo($_GET['aut_id']) ?><span></td>
     <td class="textotablamenuform">&nbsp;Total Costo :</td>
    <td class="textotablamenuform">&nbsp;<span style="color: red;">$ <?php echo obtener_total_egresos_vehiculo($_GET['aut_id'])+$regPer['precioToma']  ?><span></td>
  </tr>
</table>

                    
                     </fieldset>
                   </td>
                   </tr>
                   
                   
                   
                   
               </table>  
        </fieldset>
       </form>
           <fieldset>
             <legend><b>Resultado de la Busqueda</b></legend>
             <a href="altaMovCajaVehiculo.php?aut_id=<?php echo $_GET['aut_id']?>"><img src="img/nuevo.png" width="25" height="25" border="0"/> Registrar Gasto</a>
             </br>

             <table id="flex1" >

               <tbody>

                <?php
                $i=1;
                if($pages->items_total >0)
                while($reg=  mysql_fetch_array($result)):?>
                  <tr id="fila<?php echo $i?>">
                     
                     <td width="60"><?php echo $reg['movFecha']?></td>
                     <td width="100"><?php   echo obtener_tipo_movimiento($reg['movRubro'])?>
                     </td>
                     <td width="250"><?php echo $reg['movConcepto']?></td>
                     <td width="150">
                     <?php if($reg['movTipo']==1)
					       echo '$ '.$reg['movMonto'];
						   else
						       echo '$ 0';
				     ?></td>
                     <td width="150">  <?php if($reg['movTipo']==2)
					       echo '$ '.$reg['movMonto'];
						   else
						       echo '$ 0';
				     ?></td>
                 </tr>
                 <?php
                 $i++;
                 endwhile
                
                 ?>

                   <tr>
                       <td colspan="8"><?php echo $pages->display_jump_menu();echo $pages->display_items_per_page();echo $pages->display_pages() ?></td>
                   </tr>
                </tbody>

             </table>
             

        </fieldset>
           
       </div>
 
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>
</body>
</html>
